#ifndef  HIDCLASS_H
#define  HIDCLASS_H
#include "usb.hpp"

namespace USBTemp
{






template<uint32_t _length>
class ClassReportDesc
{
public:
    enum{ length = _length};
};

template<class _ClassReportDesc, class _AppendClassReportDesc = _dummy>
class AppendClassReportDesc
{
public:
    enum{
            length = _ClassReportDesc::length,
            number = 1 + _AppendClassReportDesc::number,
        };
    DescValue8<DESC_HID_RPT>            _descType;
    DescValue16<length>                 _descLength;
    _AppendClassReportDesc              _remain;
};

template<class _ClassReportDesc>
class AppendClassReportDesc<_ClassReportDesc, _dummy>
{
public:
    enum{
            length = _ClassReportDesc::length,
            number = 1,
        };
    DescValue8<DESC_HID_RPT>            _descType;
    DescValue16<length>                 _descLength;
};

struct HidSubClassBoot      {   enum {v = 1};   };
struct HidSubClassNoBoot    {   enum {v = 0};   };
struct HidProtocolNone      {   enum {v = 0};   };
struct HidProtocolKeyboard  {   enum {v = 1};   };
struct HidProtocolMouse     {   enum {v = 2};   };

template<
    class _subClass = HidSubClassNoBoot, 
    class _protocol = HidProtocolNone, 
    class _EndPointList = AppendEndPoint< EndPointDesc< EpIntIn<1> >,
                          AppendEndPoint< EndPointDesc< EpIntOut<1> > 
                          > >, 
    class _ClassDescriptorList = AppendClassReportDesc< ClassReportDesc<0x1111> ,
                                 AppendClassReportDesc< ClassReportDesc<0x2222> 
                                      > >,
    uint16_t HidRelease = 0x200, 
    uint8_t targetCountry = 0>
class HidDescriptor
{
public:
    enum{
        length = LEN_HID + _EndPointList::length + (_ClassDescriptorList::number-1)*3,
        epCnt = _EndPointList::number,
        interfaceClass = 0x03,
        interfaceSubClass = _subClass::v,
        interfaceProtocol = _protocol::v,
        epInUsage = _EndPointList::epInUsage,
        epOutUsage = _EndPointList::epOutUsage,
    };
    DescValue8<LEN_HID>                         _len;
    DescValue8<DESC_HID>                        _desc;
    DescValue16<HidRelease>                     _release;
    DescValue8<targetCountry>                   _country;
    DescValue8<_ClassDescriptorList::number>    _descNumber;
    _ClassDescriptorList                        _classDesc;
    _EndPointList                               _epDesc;
};















};

#endif


